﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel;
using SuperFox.SuperServiceReference;

namespace SuperFox
{
    public static class ServiceConfig
    {
        public static SuperServiceClient Connect()
        {


            String serviceUri = "";

            if (System.Windows.Browser.HtmlPage.Document.DocumentUri.Host.Contains("localhost"))
            {
                serviceUri = Config.LOCAL_SERVICE_PATH;

            }else if(System.Windows.Browser.HtmlPage.Document.DocumentUri.Host.Contains("beta"))
            {
                serviceUri = Config.BETA_REMOTE_SERVICE_PATH;

            }else
            {
                if(System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri.Contains("www"))
                {
                    serviceUri = Config.REMOTE_SERVICE_PATH_WWW;
                }else
                {
                    serviceUri = Config.REMOTE_SERVICE_PATH;
                }

            }

            BasicHttpBinding binding = new BasicHttpBinding();
            binding.MaxBufferSize = Config.SERVICE_MAX_BUFFER_SIZE;
            binding.MaxReceivedMessageSize = Config.SERVICE_MAX_RECEIVE_BUFFER_SIZE;

            return new SuperServiceClient(binding, new System.ServiceModel.EndpointAddress(serviceUri));
        }
    }
}
